package com.rs.service.map.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.rs.entity.basic.MapDataLineVO;
import com.rs.entity.basic.MapDataPointVO;
import com.rs.entity.basic.MapInfo;
import com.rs.entity.basic.RcsMap;
import com.rs.mapper.map.MapMapper;
import com.rs.processor.MapInitProcessor;
import com.rs.service.map.IMapDataService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 地图实现类
 *
 * @author zhouwz
 * @date 2020/3/19 14:38
 */
@Slf4j
@Service
public class MapDataServiceImpl extends ServiceImpl<MapMapper, RcsMap> implements IMapDataService {

    private final MapInitProcessor mapInitProcessor;

    public MapDataServiceImpl(MapInitProcessor mapInitProcessor) {
        this.mapInitProcessor = mapInitProcessor;
    }

    @Override
    public MapInfo getMapData(String mapNo) {
        List<MapDataPointVO> pointList = this.baseMapper.getDataPointDetail(mapNo);
        List<MapDataLineVO> lineList = this.baseMapper.getDataLineList(mapNo);
        MapInfo mapInfo = new MapInfo();
        // 点位信息处理
        mapInitProcessor.pointHandler(mapInfo, pointList);
        // 线信息处理
        mapInitProcessor.lineHandler(mapInfo, lineList, pointList);
        return mapInfo;
    }
}